<?php
session_start();
if ($_SESSION['auth'] != true && $_SESSION['rule'] != "PUBLISHER") {
	die('Not log in');
}
include("includes/publisher_lib.php");

switch($_GET['action']){
case "approve_item":
	setPublish($_POST['itemid'],$_SESSION['userdata']['username']);
	editItem($_POST['itemid'],$_POST['addToCh'],$_POST['title'],$_POST['link']
		,$_POST['description'],$_POST['guid'],"");
	echo "Approved";
	break;
case "unapprove_item":
	setNotPublish($_POST['itemid'],$_SESSION['userdata']['username']);
	echo "Unapproved";
	break;
case "update_suspend":
	$lastMo = lastModified();
	if($lastMo != $_SESSION['time_update_publisher'] 
			|| empty($_SESSION['time_update_publisher'])
			|| $_GET['init'] == "init"){
		$_SESSION['time_update_publisher'] = $lastMo;
		$suspend = getAllNotPublish($_SESSION['userdata']['username']);
		if($suspend != ''){
			echo "<table width='100%'>";
			foreach($suspend as $e)
			{
				echo "<tr><td>";
				echo "<a href=\"#\" onclick=\"document.getElementById('main-right-box').src
						='publisher_approve_item.php?id=".$e['id']."'\">".$e['title']."</a>";
				echo "</td></tr>";
				//To-Do change 'pubdate' to 'modified date'
				echo "<tr><td style='font-size:x-small'>".$e[pubdate]."</td></tr>";
				echo "<tr><td style='font-size:x-small'>";
				echo $e['channel']." - by ".$e['author'];
				echo "<br /></tr></td>";
			}
			echo "</table>";
		}
	}else{
		echo $NO_UPDATE;
	}
	break;
default:
	echo "Oh shit";
	break;
}
?>